<?php

namespace App\V3\V3_2_7\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TextImageModel extends Model
{


    use HasFactory;
    const    PAGESIZE  = 1;
    protected $table   = 'text_image';

    /**
     * 新建文字图片画册
     */
    static public function addTextImage($data){

        return TextImageModel::insertGetId($data);
    }

    /**
     * 查询单个文字图片画册信息
     *
     */
    static public function getTextImageInfo($condition){

        return TextImageModel::where($condition)->first();
    }

    /**
     * 查询多个文字图片画册信息
     *
     */
    static public function getTextImageInfos($condition,$ids_arr){

        return TextImageModel::select(
            'id',
            'p_a_name',
            'album_cover_img',
            'background_music'
            )->where($condition)
            ->whereIn('id',$ids_arr)->get()->toArray();
    }
    /**
     * 修改文字图片画册信息
     *
     */
    static public function updTextImage($condition,$data){

        $data['update_time'] = time();
        return TextImageModel::where($condition)->update($data);
    }
    /**
     * 删除文字图片画册信息
     *
     */
    static public function delTextImage($condition,$pa_id_arr){

        return TextImageModel::where($condition)->whereIn('id',$pa_id_arr)->delete();
    }
    /**
     * 文字图片画册列表
     */
    static public function getTextImageList($condition,$currentPage,$pageSize){

        return  TextImageModel::select('ti.*')->from('text_image AS ti')
        ->leftJoin('admin AS ad', 'ti.user_id', '=', 'ad.id')
        ->where($condition)
        ->orderBy('ti.create_time', 'DESC')
        ->paginate($pageSize,['*'], '',$currentPage)
        ->toArray();

    }
}
